* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(200deg, #e7f0fd, #accbee);
}

.container {
    position: relative;
    display: flex;
    flex-direction: row;
    // 允许换行
    flex-wrap: wrap;
    .box {
        position: relative;
        width: 275px;
        height: 275px;
        overflow: hidden;
        transition: 0.5s;
        &:hover {
            transform: scale(1.25);
            box-shadow: 0 25px 40px rgba(0, 0, 0, 0.5);
            z-index: 1;
            .img-box::before {
                opacity: 1;
            }
            .text-box{
                h2 {
                    transform: translateY(0);
                    transition-delay: 0.3s;
                }
                p {
                    transform: translateY(0);
                    transition-delay: 0.4s;
                }
            }
        }
        .text-box {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            padding: 20px;
            display: flex;
            // 元素位于容器的结尾
            align-items: flex-end;
            color: #fff;
            z-index: 2;
            h2 {
                font-size: 20px;
                margin-bottom: 10px;
                transform: translateY(200px);
                transition: 0.5s;
            }
            p {
                font-size: 13px;
                line-height: 20px;
                transform: translateY(200px);
                transition: 0.5s;
            }
        }
        .img-box {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            &::before {
                content: '';
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                background: linear-gradient(to top, #222, transparent);
                z-index: 1;
                opacity: 0;
                transition: 0.5s;
            }
            img {
                position: absolute;
                left: 0;
                top: 0;
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
        }
    }
}
